package org.ccay.excel.importer;


/**
 * 行错误对象	
 * @author chaowangbang
 * @since 2011-12-25
 */
public class ExcelCellError {
	/**
	 * Sheet号
	 */
	private String sheetName;
	/**
	 * 行号
	 */
	private int rowIndex;
	/**
	 * 列号
	 */
	private String columnIndex;
	/**
	 * 错误信息
	 */
	private String errorMessage;
	
	public ExcelCellError(){}
	
	public ExcelCellError(String sheetName, int rowIndex, String columnIndex, String errorMessage) {
		this.sheetName = sheetName;
		this.rowIndex = rowIndex;
		this.columnIndex = columnIndex;
		this.errorMessage = errorMessage;
	}
	/**
	 * @return the columnIndex
	 */
	public String getColumnIndex() {
		return columnIndex;
	}
	/**
	 * @param columnIndex the columnIndex to set
	 */
	public void setColumnIndex(String columnIndex) {
		this.columnIndex = columnIndex;
	}
	/**
	 * @return the errorMessage
	 */
	public String getErrorMessage() {
		return errorMessage;
	}
	/**
	 * @param errorMessage the errorMessage to set
	 */
	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}
	/**
	 * @return the rowIndex
	 */
	public int getRowIndex() {
		return rowIndex;
	}
	/**
	 * @param rowIndex the rowIndex to set
	 */
	public void setRowIndex(int rowIndex) {
		this.rowIndex = rowIndex;
	}
	/**
	 * @return the sheetIndex
	 */
	public String getSheetIndex() {
		return sheetName;
	}
	/**
	 * @param sheetIndex the sheetIndex to set
	 */
	public void setSheetIndex(String sheetIndex) {
		this.sheetName = sheetIndex;
	}
	
	public String getSheetName() {
		if(sheetName.indexOf("#")!=-1){
			return sheetName.substring(0, sheetName.indexOf("#"));
		}
		return sheetName;
	}

	@Override
	public String toString() {
		StringBuilder buf = new StringBuilder();
		buf.append("[");
		buf.append("sheet:");
		buf.append(this.sheetName);
		if(this.rowIndex != 0){
			buf.append("; Row:");
			buf.append(this.rowIndex);
		}
		if(null != this.columnIndex){
			buf.append("; Col:");
			buf.append(this.columnIndex);
		}
		buf.append("] ");
		buf.append(this.errorMessage);
		return buf.toString();
	}
	/**
	 * 执行简单的错误信息
	 * @return
	 * Created：2013-8-6
	 * @author chaowangbang
	 */
	public String toErrorMessage(){
		StringBuilder buf = new StringBuilder();
		if(null != this.columnIndex){
			buf.append("[ Col:");
			buf.append(this.columnIndex);
			buf.append("] ");
			buf.append(this.errorMessage);
			buf.append("; ");
		}
		return buf.toString();
	}
}
